$(function () {
    validateData();
    $('body').on('click','#onBack',function (){
        onBackHistory();
    });
    $('body').on('click','#submitUserExprule',function (){
        saveUserExprule();
    });

    inputRadioSel($(".i-checks"),selectCall);
});
/**
 * 取消
 */
function onBackHistory() {
   window.location.href=baseloaction+"/admin/user/cus/userExpruleList"
}
/**
 * 选择回调
 */
function selectCall(em) {
    if(em.name=='type'){
        getProportionExp(em.value);
    }
}
/**
 * 控制比例分数 和固定分数
 */
var  index =0;
function getProportionExp(value) {
        if(value==2&&index==0){
            $("#userExpruleScore").addClass("input-group m-b");
            $("#userExpruleScore").append('<span  class="input-group-addon percentRemove">%</span>');
            index+=1;
            $(".userExpruleTermDepict").show();
        }else if(value!=2){
            index =0;
            $(".userExpruleTermDepict").hide();
            $("#userExpruleScore").removeClass("input-group m-b");
            $(".percentRemove").remove();
        }
}

/**
 * 提交方法
 */
function saveUserExprule() {
    var params = $("#userExpruleFrom").serializeJSON();
    params = JSON.stringify(params);
    $.ajax({
        url:baseloaction+"/admin/user/cus/saveUserExprule",
        data:params,
        type:"post",
        dataType:"json",
        contentType:'application/json;charset=utf-8',
        success:function (result) {
            if (result.success == true) {
                icModale(1,result.message,1,function () {
                    window.location.href=baseloaction+"/admin/user/cus/userExpruleList"
                });
            } else {
                icModale(0,result.message);
            }
        }
    });
}